#include <bits/stdc++.h>
using namespace std;
#define mm(a) memset(a,0,sizeof(a));
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
int main() {
    stack<char> stk;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ')') {
            string cur = ""; // 定义一个字符串去 接收栈里的表达式
            while (stk.top() != '(') {
                cur += stk.top();
                stk.pop();
            }
            stk.pop(); // pop 出‘（’
            int j;
            int MAX = 0, cnt = 0;
            for (j = 0; j < cur.length(); j++) {
                if (cur[j] == '|') {
                    MAX = max(MAX, cnt);
                    cnt = 0;
                } else {
                    cnt++;
                }
            }
            MAX = max(MAX, cnt);
            while (MAX--) stk.push('x');
        } else {
            stk.push(s[i]);
        }
    }

    string cur = "";
    while (!stk.empty()) {
        cur += stk.top();
        stk.pop();
    }
    int j;
    int MAX = 0, cnt = 0;
    for (j = 0; j < cur.length(); j++) {
        if (cur[j] == '|') {
            MAX = max(MAX, cnt);
            cnt = 0;
        } else {
            cnt++;
        }
    }
    MAX = max(MAX, cnt);
    cout << MAX << endl;
    return 0;
}